import axios from 'axios';
import {  req } from './axiosfun';

export const userList = (params) => { return req("post", "/api/User/GetUserList", params) };

export const getInfo=(params)=>{
    console.log(params);
    return req("get","/api/Report/Year?Year="+params.year+"&Type="+params.type,params)
};
// 通过年份获取各类型目标数.
// export function getInfo(year,type) {
//     return request({
//         // url: `/api/Business/QmsBusiCustomerComplaintReport/${year}`,
//         url: `/api/Business/QmsBusiCustomerComplaintReport/Year?Year=`+year+"&Type="+type,
//         method: 'GET'
//     })
// }

// 新建客户投诉报表目标数.
export function create(type,data) {
    console.log(data);
    return req("put",`/api/Report/${type}`,data)
    // return req({
    //     url: `/api/Report/${Type}`,
    //     method: 'put',
    //     data
    // })
}
// export function create(type,data) {
//     return request({
//         url: `/api/Business/QmsBusiCustomerComplaintReport/${type}`,
//         method: 'put',
//         data
//     })
// }
//获取table数据.
export function getTable(year,problemAttribution) {
    return req("GET","/api/Report?Year="+year+"&ProblemAttribution="+problemAttribution)
    // return request({
    //     // url: `/api/Business/QmsBusiCustomerComplaintReport?Year=${year}"&ProblemAttribution="${problemAttribution}`,
    //     url: `/api/Business/QmsBusiCustomerComplaintReport?Year=`+year+"&ProblemAttribution="+problemAttribution,
    //     method: 'GET'
    // })
}

//获取echarts数据.
export function getEcharts(year,problemAttribution,complaintType) {
    return req("GET","/api/Report/LineChart?Year="+year+"&ProblemAttribution="+problemAttribution+"&ComplaintType="+complaintType)
}
// export function getEcharts(year,problemAttribution,complaintType) {
//     return request({
//         // url: `/api/Business/QmsBusiCustomerComplaintReport?Year=${year}"&ProblemAttribution="${problemAttribution}`,
//         url: `/api/Business/QmsBusiCustomerComplaintReport/LineChart?Year=`+year+"&ProblemAttribution="+problemAttribution+"&ComplaintType="+complaintType,
//         method: 'GET'
//     })
// }

export function customerReport(year){
    return request({
        url: `/api/Business/QmsBusiCustomerComplaintReport/CustomerStatisticalChart?Year=`+year,
         method:"Get"
    })
}
//整机配件导出接口
export function exportformalCustomer(type,year){
    return request({
        url:"/api/Business/QmsBusiCustomerComplaintReport/Actions/Export?Type="+type+"&Year="+year,
        method:"GET"
    })
}
//客户报表导出接口
export function exportCustomer(year){
    return request({
        url:"/api/Business/QmsBusiCustomerComplaintReport/Actions/CustomerExport?Year="+year,
        method:"GET"
    })
}

export default {
    getInfo,
    create,
    getTable,
    getEcharts,
    customerReport,
    exportformalCustomer,
    exportCustomer
};